<template>
  <view class="delete-account-container">
    <e-navbar leftTitle="注销账号"></e-navbar>
    <view class="p-t-80 p-b-70 pingfang-heavy text-bold" style="font-size: 48rpx">申请注销{{userinfo.mobile ? userinfo.mobile.slice(0,4) + '*****' + userinfo.mobile.slice(-3) : userinfo.nickname}}账号</view>
    <view class="text-content">
      <view class="" style="color: #1F66FF">注销账号为不可恢复操作，注销账号后您将无法找回本账号及本账号相关的内容与信息</view>
      <view>在您注销易小语账号之前，请您认真阅读，理解并同意以下内容:</view>
      <view class="text-666">1、注销账号需满足以下条件:该账户名下已无待处理订单账号状态正常;</view>
      <view class="text-666">
        <text>2、该操作将会删除你的账号及数据，</text>
        <text class="" style="color: #FF3C3C">且不能重新注册，包含手机号以及实名信息不能重新使用:</text>
      </view>
      <view class="text-666">3、注销账号并不代表注销前的账号中的行为相关责任得到豁免或减轻。我理解并同意注销</view>
    </view>
    <u-gap height="100"></u-gap>
    <view class="main-btn m-30">
      <u-button text="我理解并同意注销" color="#1F66FF" @click="handleConfirmBtn"></u-button>
    </view>
    <e-popup ref="deleteAccountPopup" @close="handleClosePopup" @confirm="handleConfirmPopup"></e-popup>
  </view>
</template>

<script>
export default {
  data() {
    return {
			userinfo:{},
		};
  },
	onLoad() {
		let userinfo = uni.getStorageSync('userinfo');
		if(userinfo){
			this.userinfo = JSON.parse(userinfo);
		}
	},
  methods: {
    handleConfirmBtn(){
      this.$refs.deleteAccountPopup.handleShowPopup("是否确认注销账号?");
    },
    handleClosePopup(){
      this.$refs.deleteAccountPopup.handleClosePopup();
    },
    async handleConfirmPopup(){
      const res = await this.$api.write_off();
      if(res.code == 1){
        this.handleClosePopup();
        this.$u.toast("注销成功");
        uni.clearStorageSync();
        setTimeout(()=>{
          uni.switchTab({
            url: '/pages/index/index'
          })
        },500)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .delete-account-container{
    padding: 0 30rpx;
    .text-content{
      line-height: 48rpx;
      font-size: 26rpx;
    }
  }
</style>
